home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / excell1a / form5.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-10-10  |  9.4 KB  |  326 lines

  1. VERSION 5.00
  2. Begin VB.Form Form5 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "User Dictioary"
  5.    ClientHeight    =   4620
  6.    ClientLeft      =   45
  7.    ClientTop       =   330
  8.    ClientWidth     =   7440
  9.    ControlBox      =   0   'False
  10.    LinkTopic       =   "Form5"
  11.    MaxButton       =   0   'False
  12.    MinButton       =   0   'False
  13.    ScaleHeight     =   4620
  14.    ScaleWidth      =   7440
  15.    StartUpPosition =   2  'CenterScreen
  16.    Begin VB.CommandButton cmdOk 
  17.       Caption         =   "&Ok"
  18.       Default         =   -1  'True
  19.       Height          =   375
  20.       Left            =   5520
  21.       TabIndex        =   7
  22.       Top             =   4080
  23.       Width           =   855
  24.    End
  25.    Begin VB.CommandButton cmdAdd 
  26.       Caption         =   "&Add"
  27.       Enabled         =   0   'False
  28.       Height          =   375
  29.       Left            =   6480
  30.       TabIndex        =   3
  31.       Top             =   1680
  32.       Width           =   855
  33.    End
  34.    Begin VB.CommandButton cmdDelete 
  35.       Caption         =   "&Delete"
  36.       Enabled         =   0   'False
  37.       Height          =   375
  38.       Left            =   3840
  39.       TabIndex        =   5
  40.       Top             =   3600
  41.       Width           =   855
  42.    End
  43.    Begin VB.CommandButton cmdModify 
  44.       Caption         =   "&Modify"
  45.       Enabled         =   0   'False
  46.       Height          =   375
  47.       Left            =   3840
  48.       TabIndex        =   6
  49.       Top             =   4080
  50.       Width           =   855
  51.    End
  52.    Begin VB.CommandButton cmdClose 
  53.       Cancel          =   -1  'True
  54.       Caption         =   "&Cancel"
  55.       Height          =   375
  56.       Left            =   6480
  57.       TabIndex        =   8
  58.       Top             =   4080
  59.       Width           =   855
  60.    End
  61.    Begin VB.ListBox List1 
  62.       BeginProperty Font 
  63.          Name            =   "Tahoma"
  64.          Size            =   8.25
  65.          Charset         =   0
  66.          Weight          =   400
  67.          Underline       =   0   'False
  68.          Italic          =   0   'False
  69.          Strikethrough   =   0   'False
  70.       EndProperty
  71.       Height          =   4350
  72.       ItemData        =   "Form5.frx":0000
  73.       Left            =   120
  74.       List            =   "Form5.frx":0002
  75.       Sorted          =   -1  'True
  76.       TabIndex        =   4
  77.       Top             =   120
  78.       Width           =   3615
  79.    End
  80.    Begin VB.TextBox txtSubject 
  81.       Height          =   315
  82.       Left            =   3960
  83.       TabIndex        =   1
  84.       Top             =   480
  85.       Width           =   3375
  86.    End
  87.    Begin VB.TextBox txtWord 
  88.       Height          =   315
  89.       Left            =   3960
  90.       TabIndex        =   2
  91.       Top             =   1200
  92.       Width           =   3375
  93.    End
  94.    Begin VB.Label lblCopying 
  95.       AutoSize        =   -1  'True
  96.       Caption         =   "Copying..............."
  97.       BeginProperty Font 
  98.          Name            =   "MS Sans Serif"
  99.          Size            =   12
  100.          Charset         =   0
  101.          Weight          =   400
  102.          Underline       =   0   'False
  103.          Italic          =   0   'False
  104.          Strikethrough   =   0   'False
  105.       EndProperty
  106.       Height          =   300
  107.       Left            =   5520
  108.       TabIndex        =   11
  109.       Top             =   3600
  110.       Visible         =   0   'False
  111.       Width           =   1755
  112.    End
  113.    Begin VB.Label Label1 
  114.       Caption         =   $"Form5.frx":0004
  115.       Height          =   855
  116.       Left            =   3840
  117.       TabIndex        =   10
  118.       Top             =   2280
  119.       Width           =   3495
  120.    End
  121.    Begin VB.Label lblData 
  122.       AutoSize        =   -1  'True
  123.       Caption         =   "Subject:"
  124.       Height          =   195
  125.       Index           =   1
  126.       Left            =   3960
  127.       TabIndex        =   9
  128.       Top             =   240
  129.       Width           =   585
  130.    End
  131.    Begin VB.Label lblData 
  132.       AutoSize        =   -1  'True
  133.       Caption         =   "Word:"
  134.       Height          =   195
  135.       Index           =   0
  136.       Left            =   3960
  137.       TabIndex        =   0
  138.       Top             =   960
  139.       Width           =   435
  140.    End
  141. Attribute VB_Name = "Form5"
  142. Attribute VB_GlobalNameSpace = False
  143. Attribute VB_Creatable = False
  144. Attribute VB_PredeclaredId = True
  145. Attribute VB_Exposed = False
  146. Dim ListNum
  147. Private Sub cmdAdd_Click()
  148.     Dim tempsub
  149.     Dim tempword
  150.     Dim temp
  151.     Dim temp2
  152.     Dim num1
  153.     Dim num2
  154.     If Len(txtSubject) > 30 Then
  155.     Dim response
  156.     Dim sublen2
  157.     Dim sublen
  158.     sublen = Len(txtSubject.Text)
  159.         response = MsgBox("The subect is" + Str(sublen) + " letters long, please don't use more then 30 letters.", vbOKOnly + vbExclamation, "Error")
  160.     Exit Sub
  161.     End If
  162.     tempsub = txtSubject.Text
  163.     tempword = txtWord.Text
  164.     num1 = Len(tempsub)
  165.     num2 = 30 - num1
  166.     Do While num2 > 0
  167.         temp2 = temp2 + " "
  168.         num2 = num2 - 1
  169.     Loop
  170.     temp = tempsub + temp2 + tempword
  171.     Dim num3
  172.     num3 = Len(temp)
  173.     List1.AddItem temp
  174.     txtWord = ""
  175.     txtSubject = ""
  176.     txtSubject.SetFocus
  177. End Sub
  178. Private Sub cmdClose_Click()
  179.     Form2.Enabled = True
  180.     Unload Me
  181. End Sub
  182. Private Sub cmdDelete_Click()
  183.     List1.RemoveItem ListNum
  184.     List1.ListIndex = ListNum - 1
  185.     If List1.ListCount < 1 Then
  186.         cmdDelete.Enabled = False
  187.         cmdModify.Enabled = False
  188.     End If
  189. End Sub
  190. Private Sub cmdModify_Click()
  191.     Dim temp
  192.     Dim tempsub
  193.     Dim tempword
  194.     temp = List1.Text
  195.     tempsub = Left(temp, 30)
  196.     tempsub = Trim(tempsub)
  197.     tempword = Mid(temp, 31)
  198.     txtSubject.Text = tempsub
  199.     txtWord.Text = tempword
  200. End Sub
  201. Private Sub cmdOk_Click()
  202.     If List1.ListCount = 0 Then
  203.         Dim response
  204.         response = MsgBox("You must have at least one entry in the list.", vbOKOnly + vbExclamation, "Error")
  205.         Exit Sub
  206.     End If
  207.     Dim AddNum
  208.     Dim AddTemp
  209.     lblCopying.Visible = True
  210.     Form5.Refresh
  211.     List1.Visible = False
  212.     Form5.Enabled = False
  213.     AddNum = 0
  214.     Set fs = CreateObject("Scripting.FileSystemObject")
  215.     Set a = fs.CreateTextFile("c:\windows\temp\tempfile.txt", True)
  216.     Do While AddNum <> List1.ListCount
  217.         List1.ListIndex = AddNum
  218.         AddTemp = List1.Text
  219.         a.WriteLine (AddTemp)
  220.         AddNum = AddNum + 1
  221.     Loop
  222.     a.Close
  223.     FileCopy "C:\windows\temp\tempfile.txt", "Dictionary.txt"
  224.     Form5.Enabled = True
  225.     Form2.Enabled = True
  226.     List1.Visible = True
  227.     lblCopying.Visible = False
  228.     Dim del As Object
  229.     Kill "C:\windows\temp\tempfile.txt"
  230.     Unload Me
  231. End Sub
  232. Private Sub Form_Load()
  233.     Dim AddIt
  234.     Open "dictionary.txt" For Input As #1 ' Open file for input.
  235.         Do While Not EOF(1)   ' Check for end of file.
  236.             Line Input #1, AddIt  ' Read line of data.
  237.             List1.AddItem AddIt  ' Print to the Immediate window.
  238.         Loop
  239.     Close #1   ' Close file.
  240. End Sub
  241. Private Sub Label1_Click()
  242. End Sub
  243. Private Sub List1_Click()
  244.     If List1.ListCount > 0 Then
  245.         cmdModify.Enabled = True
  246.         cmdDelete.Enabled = True
  247.         cmdModify.Default = True
  248.     End If
  249.     ListNum = List1.ListIndex
  250. End Sub
  251. Private Sub txtSubject_Change()
  252.     txtSubject.MaxLength = 30
  253.         
  254.     If txtWord.Text = "" Then
  255.         cmdAdd.Enabled = False
  256.         cmdOk.Default = True
  257.     Else
  258.         If txtSubject = "" Then
  259.             cmdAdd.Enabled = False
  260.             cmdOk.Default = True
  261.         Else
  262.                 cmdAdd.Enabled = True
  263.                 cmdAdd.Default = True
  264.         End If
  265.     End If
  266. End Sub
  267. Private Sub txtSubject_Click()
  268.     cmdDelete.Enabled = False
  269.     cmdModify.Enabled = False
  270.     cmdOk.Default = True
  271.     If txtWord.Text = "" Then
  272.         cmdAdd.Enabled = False
  273.         cmdOk.Default = True
  274.     Else
  275.         If txtSubject = "" Then
  276.             cmdAdd.Enabled = False
  277.             cmdOk.Default = True
  278.         Else
  279.                 cmdAdd.Enabled = True
  280.                 cmdAdd.Default = True
  281.         End If
  282.     End If
  283. End Sub
  284. Private Sub txtWord_Change()
  285.     txtWord.MaxLength = 35
  286.     If txtWord.Text = "" Then
  287.         cmdAdd.Enabled = False
  288.         cmdOk.Default = True
  289.     Else
  290.         If txtSubject = "" Then
  291.             cmdAdd.Enabled = False
  292.             cmdOk.Default = True
  293.         Else
  294.                 cmdAdd.Enabled = True
  295.                 cmdAdd.Default = True
  296.         End If
  297.     End If
  298.     cmdDelete.Enabled = False
  299.     cmdModify.Enabled = False
  300. End Sub
  301. Private Sub txtWord_Click()
  302.     cmdDelete.Enabled = False
  303.     cmdModify.Enabled = False
  304.     cmdOk.Default = True
  305.     If txtWord.Text = "" Then
  306.         cmdAdd.Enabled = False
  307.         cmdOk.Default = True
  308.     Else
  309.         If txtSubject = "" Then
  310.             cmdAdd.Enabled = False
  311.             cmdOk.Default = True
  312.         Else
  313.                 cmdAdd.Enabled = True
  314.                 cmdAdd.Default = True
  315.         End If
  316.     End If
  317. End Sub
  318. Private Sub txtWord_GotFocus()
  319.     txtWord.SelStart = 0
  320.     txtWord.SelLength = Len(txtWord.Text)
  321. End Sub
  322. Private Sub txtSubject_GotFocus()
  323.     txtSubject.SelStart = 0
  324.     txtSubject.SelLength = Len(txtSubject.Text)
  325. End Sub
  326.